import java.util.Date;

import com.pi4j.io.gpio.GpioController;
import com.pi4j.io.gpio.GpioFactory;
import com.pi4j.io.gpio.GpioPinDigitalInput;
import com.pi4j.io.gpio.GpioPinDigitalOutput;
import com.pi4j.io.gpio.Pin;
import com.pi4j.io.gpio.PinPullResistance;
import com.pi4j.io.gpio.PinState;
import com.pi4j.io.gpio.RaspiPin;
import com.pi4j.util.CommandArgumentParser;
import com.pi4j.util.Console;


public class hwx {

	public static void main(String[] args) throws InterruptedException {
		final Console console = new Console();

        // print program title/header
        console.title("<-- The Pi4J Project -->", "GPIO Input Example");

        // allow for user to exit program using CTRL-C
        console.promptForExit();
        
		 final GpioController gpio = GpioFactory.getInstance();

	        // by default we will use gpio pin #01; however, if an argument
	        // has been provided, then lookup the pin by address

	        // by default we will use gpio pin PULL-UP; however, if an argument
	        // has been provided, then use the specified pull resistance
	        PinPullResistance pull = CommandArgumentParser.getPinPullResistance(
	                PinPullResistance.PULL_UP,  // default pin pull resistance if no pull argument found
	                args);                      // argument array to search in
	        
	        // provision gpio pin as an input pin
	        final GpioPinDigitalInput input = gpio.provisionDigitalInputPin(RaspiPin.GPIO_28,pull);
				
	        Thread.sleep(2000);
	        while (!console.exiting()) {
				if (input.getState().isHigh()) {
					System.out.println("high");
				}else {
					System.out.println("no");
				}
				Thread.sleep(100);
			}
	        gpio.shutdown();

	}
	
}
